﻿using Smobiler.Core;
using Smobiler.Core.Controls;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using Model;
using DAL;
namespace FubiManger.UI
{
    partial class StaffsForm : Smobiler.Core.Controls.MobileForm
    {
        public StaffsForm() : base()
        {
            //This call is required by the SmobilerForm.
            InitializeComponent();
        }
        /// <summary>
        /// 商户ID
        /// </summary>
        public string merchantid { get; set; }
        private void panclose_Press(object sender, EventArgs e)
        {
            this.Close();
        }

        private void StaffsForm_Load(object sender, EventArgs e)
        {
            Getstaff();
        }
        /// <summary>
        /// 获取员工
        /// </summary>
        private void Getstaff()
        {
            List<ms_admins> adminlist = new List<ms_admins>();
            adminlist = adminsDal.Querybymerchantid(merchantid);//查子账号
            DataTable table = new DataTable();
            table.Columns.Add("username");
            table.Columns.Add("type");
            table.Columns.Add("nickname");
            table.Columns.Add("time");
            table.Columns.Add("status");
            if (lvstaff.Rows.Count > 0)
                lvstaff.Rows.Clear();
            for (int i = 0; i < adminlist.Count; i++)
            {
                table.Rows.Add(adminlist[i].username, adminlist[i].admintype, "姓名：" + adminlist[i].nickname, "创建时间：" + adminlist[i].register_time, adminlist[i].status);
            }
            lvstaff.DataSource = table;
            lvstaff.DataBind();
        }
        /// <summary>
        /// 刷新
        /// </summary>
        public void Resfh()
        {
            Getstaff();
        }
        /// <summary>
        /// 添加员工
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnadd_Press(object sender, EventArgs e)
        {
            StaffForm frm = new StaffForm();
            frm.merchantid = merchantid;//商户ID
            this.Form.Show(frm, true, (obj, args) =>
            {                
                Getstaff();
            });
        }
    }
}